﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Windows.Controls;
using JMT.Data;

namespace JMT.Controls.Commands
{
    public class AddUIInterfaceCommand : ICommand
    {
        private ContextMenu _contextMenu;
        private MenuItem _menuItem;

        public AddUIInterfaceCommand(ContextMenu contextMenu, MenuItem menuItem)
        {
            _contextMenu = contextMenu;
            _menuItem = menuItem;
        }

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            ClassDiagram pnl = _contextMenu.Tag as ClassDiagram;
            IJContainer<JInterface> jContainer = _contextMenu.DataContext as IJContainer<JInterface>;

            JInterface jModel = new JInterface();
            jModel.Id = Guid.NewGuid();
            jModel.Name = string.Format("{0}{1}", JConstString.TInterface, jContainer.GetUniqueIndex<JInterface>());
            jContainer.Add(jModel);

            pnl.AddElement(jModel);
        }
    }
}
